home *** CD-ROM | disk | FTP | other *** search
- /*
- Copyright © 1991-1995 by TopSoft Inc. All rights reserved.
-
- You may distribute this file under the terms of the TopSoft
- Artistic License, accompanying this package.
-
- This file was developed by George (ty) Tempel in connection with TopSoft, Inc..
- See the Modification History for more details.
-
- Product
- About Box
-
- FILE
- ABUEnvDragMgr.c
-
- NAME
- ABUEnvDragMgr.c, part of the ABox project source code,
- responsible for mix-in handling the AboutBox DragMgr environment stuff.
-
- DESCRIPTION
- This file contains defines for the about box modules.
-
- DEVELOPED BY
- George (ty) Tempel netromancr@aol.com
- All code in this file, and its associated header file was
- Created by George (ty) Tempel in connection with the TopSoft, Inc.
- "FilterTop" application development, except where noted.
-
- CARETAKER - George (ty) Tempel <netromancr@aol.com>
- Please consult this person for any changes or suggestions to this file.
-
- MODIFICATION HISTORY
-
- dd mmm yy - xxx - patchxx: description of patch
- 27 June 94 - ty - Initial Version Created
- 20-july-94 - ty - initial version released
- 28-july-94 - ty - fixes to watch for Region errors during drag process
- 1-aug-94 - ty - added code to deal with the DragSendProc
- 27-apr-95 - ty - 1.0.7--fixed detection for the drag manager, since
- a bug was reported when running on Sys 7.1
- French-Canadian system (!)...thanks simon!
- 23-may-95 - ty - changes for compatibility with the CodeWarrior CW6
- release and the associated Universal Headers from Apple:
- most methods that returned references now have "Ref" at
- the end of their methods names to prevent possible collisions
- with datatypes and classes of the same name (older versions
- of the compiler didn't have a problem with this).
-
- */
-
- /*===========================================================================*/
-
- /*======= Segmentation directives ========*/
-
- #ifdef USE_MANUAL_SEGMENTATION
- #pragma segment ty
- #endif
-
- /*============ Header files ==============*/
-
- #include "ABUEnvDragMgr.h"
-
- /*=============== Globals ================*/
-
- /*================ CODE ==================*/
-
-
- /*=============================== ABUEnvDragMgr::ABUEnvDragMgr ================================*/
- ABUEnvDragMgr::ABUEnvDragMgr(void)
- {
- mDragReference = NULL;
- mItemReference = (ItemReference)1;
- mDragRegion = NULL;
- mDragRect.left = mDragRect.right = mDragRect.top = mDragRect.bottom = 0;
- mDragUPP = NULL;
- mDragMgrEvent = NULL;
- mDragInitialized = false;
- } // end ABUEnvDragMgr
-
-
-
- /*=============================== ABUEnvDragMgr::~ABUEnvDragMgr ================================*/
- ABUEnvDragMgr::~ABUEnvDragMgr(void)
- {
- this->End();
- } // end ~ABUEnvDragMgr
-
-
-
- /*=============================== ABUEnvDragMgr::IsPresent ================================*/
- Boolean ABUEnvDragMgr::IsPresent(void)
- {
- if (this->CheckGestalt(gestaltDragMgrAttr) == noErr)
- {
- this->IndicatorRef() = this->Attribute(0);
-
- } else {
- this->IndicatorRef() = false;
- }
-
- return this->IndicatorRef();
- } // end IsPresent
-
-
-
- /*=============================== ABUEnvDragMgr::OutlineRegion ================================*/
- OSErr ABUEnvDragMgr::OutlineRegion(void)
- {
- OSErr error = noErr;
- RgnHandle tempRegion;
-
- // begin here...
-
- tempRegion = ::NewRgn();
- if (!tempRegion)
- return memFullErr;
-
- // 1.0.6 ty...added check for the dragRegion having been
- // created properly
- if (this->DoesntHaveDragRegionRef())
- return memFullErr;
-
- ::CopyRgn (this->DragRegionRef(), tempRegion);
- error = ::QDError();
- if (error)
- return error;
-
- ::InsetRgn (tempRegion, 1, 1);
- error = ::QDError();
- if (error)
- return error;
-
- ::DiffRgn (this->DragRegionRef(), tempRegion, this->DragRegionRef());
- error = ::QDError();
- if (error)
- return error;
-
- ::DisposeRgn(tempRegion);
- error = ::QDError();
- return error;
-
- } // end OutlineRegion
-
-
-
-
- /*=============================== ABUEnvDragMgr::Initialize ================================*/
- OSErr ABUEnvDragMgr::Initialize(void)
- {
- OSErr error;
-
- // OVERRIDE THIS FUNCTION, but be sure to invoke this one from the
- // overriding function!
-
- if (!this->IsPresent())
- {
- return paramErr;
- } else if (this->IsDragInitialized()) {
- return noErr;
- } // end if block
-
- error = ::NewDrag(&(this->DragRef()));
- if (error)
- return error;
-
- this->DragInitializedRef() = true;
- this->DragRegionRef() = ::NewRgn();
- if (this->DoesntHaveDragRegionRef())
- return memFullErr;
-
- this->DragUPPRef() = NewDragSendDataProc (SendProc);
- if (this->DoesntHaveDragUPPRef())
- return paramErr;
-
-
- return error;
-
- } // end Initialize
-
-
-
-
- /*=============================== ABUEnvDragMgr::Begin ================================*/
- OSErr ABUEnvDragMgr::Begin(void)
- {
- OSErr error = paramErr;
-
- // OVERRIDE THIS FUNCTION!
- if (this->IsPresent() && this->IsDragInitialized() && this->HasDragMgrEventRef())
- {
- // set the draggable item's bounding rectangle
- error = this->MakeDragRegion ();
-
- // 1.0.6 ty...extended the error checking the the
- // line below to avoid region problems.
- //
- if (!error && this->HasDragRegionRef() && this->HasDragRef())
- {
- // draw a hollow thing...
- error = this->OutlineRegion ();
- if (!error)
- // 1.0.7 ty...set the drag send proc just in case
- error = ::SetDragSendProc (this->DragRef(), this->DragUPPRef(), NULL);
-
- if (!error)
- // now do the drag...
- error = ::TrackDrag (this->DragRef(),
- this->DragMgrEventRef(),
- this->DragRegionRef());
- } else {
- error = paramErr;
- } // end if block
- } // end if block
-
- return error;
-
- } // end Begin
-
-
-
-
-
- /*=============================== ABUEnvDragMgr::End ================================*/
- OSErr ABUEnvDragMgr::End(void)
- {
- // OVERRIDE THIS FUNCTION!
-
- if (this->HasDragUPPRef())
- {
- DisposeRoutineDescriptor (this->DragUPPRef());
- this->DragUPPRef() = NULL;
- } // end if block
-
- if (this->HasDragRef() && this->IsPresent())
- {
- ::DisposeDrag(this->DragRef());
- this->DragRef() = NULL;
- } // end if block
-
- if (this->HasDragRegionRef())
- {
- ::DisposeRgn(this->DragRegionRef());
- this->DragRegionRef() = NULL;
- } //
-
- this->DragInitializedRef() = false;
- return noErr;
-
- } // end End
-
-
-
-
- /*=============================== ABUEnvDragMgr::GetDropLocationDirectory ================================*/
- OSErr ABUEnvDragMgr::GetDropLocationDirectory( AEDesc *dropLocation,
- long *directoryID,
- short *volumeID)
- {
- OSErr error;
- AEDesc targetDescriptor; // 'fss ' descriptor for target directory
- FSSpec targetLocation; // FSSpec for target directory
- CInfoPBRec getTargetInfo; // paramBlock to get targetDirID
-
- // Coerce the 'alis' descriptor to a 'fss ' descriptor
- error = ::AECoerceDesc(dropLocation, typeFSS, &targetDescriptor);
- if (error)
- return error;
-
- // Extract the FSSpec from targetDescriptor
- ::BlockMove((Ptr)(*targetDescriptor.dataHandle), (Ptr)&targetLocation, sizeof(FSSpec));
-
- error = ::AEDisposeDesc(&targetDescriptor);
- if (error)
- return error;
-
- // Use PBGetCatInfo to get the directoryID of the target directory
- // from the FSSpec
-
- getTargetInfo.dirInfo.ioNamePtr = targetLocation.name;
- getTargetInfo.dirInfo.ioVRefNum = targetLocation.vRefNum;
- getTargetInfo.dirInfo.ioFDirIndex = 0;
- getTargetInfo.dirInfo.ioDrDirID = targetLocation.parID;
-
- error = ::PBGetCatInfoSync(&getTargetInfo);
- if (error)
- return error;
-
- // return directory ID and volume reference number
-
- *directoryID = getTargetInfo.dirInfo.ioDrDirID;
- *volumeID = targetLocation.vRefNum;
-
- return error;
- } // end GetDropLocationDirectory
-
-
-
-
- /*=============================== ABUEnvDragMgr::MakeDragRegion ================================*/
- OSErr ABUEnvDragMgr::MakeDragRegion (void)
- {
- OSErr error = noErr;
- RgnHandle tempRegion;
- Point offset;
-
- // begin here...
-
- tempRegion = ::NewRgn();
- if (!(this->HasDragRegionRef() && tempRegion))
- return memFullErr;
-
- offset.h = offset.v = 0;
- ::LocalToGlobal (&offset);
- ::OffsetRect (&(this->DragRectRef()), offset.h, offset.v);
- ::RectRgn (tempRegion, &(this->DragRectRef()));
- error = ::QDError();
- if (error)
- return error;
-
- ::UnionRgn (tempRegion, this->DragRegionRef(), this->DragRegionRef());
- error = ::QDError();
- if (error)
- return error;
-
- ::DisposeRgn(tempRegion);
- error = ::SetDragItemBounds (this->DragRef(),
- this->ItemRef(),
- &(this->DragRectRef()));
- ::DisposeRgn (tempRegion);
- return error;
- } // end MakeDragRegionRef()
-
-
-
-
- /*=============================== ABUEnvDragMgr::SendProc ================================*/
- //
- // The SendProc() for the class, this static method shown below, is the high-level
- // interface between us, the class, and the DragMgr. Additionally, it is used to invoke
- // the LocalSendProc() of sub-class instances. In this manner we can provide a class-level
- // interface for the DragMgr (static functions) without sacrificing the nice subclassing
- // and virtual function characteristics of C++. The dragSendRefCon is a pointer to the
- // object instance. Neat, huh?
- //
- pascal OSErr ABUEnvDragMgr::SendProc(FlavorType theType,
- void *dragSendRefCon,
- ItemReference theItemRef,
- DragReference theDragRef)
- {
- OSErr error = noErr;
-
-
- if (dragSendRefCon)
- {
- error = ((ABUEnvDragMgr *)(dragSendRefCon))->LocalSendProc (theType,
- dragSendRefCon,
- theItemRef,
- theDragRef);
- } // end if block
-
- return error;
- } // end SendProc()
-
-
-
-
-
- /*=============================== ABUEnvDragMgr::LocalSendProc ================================*/
- //
- OSErr ABUEnvDragMgr::LocalSendProc(FlavorType /*theType*/,
- void* /*dragSendRefCon*/,
- ItemReference /*theItemRef*/,
- DragReference /*theDragRef*/)
- {
- //#pragma unused (theType, dragSendRefCon, theItemRef, theDragRef)
-
- return noErr;
-
- } // end LocalSendProc()
-
-
-
- // end of file.